package com.log.blog_backend.controller;


import com.log.blog_backend.common.Result;
import com.log.blog_backend.entity.UserInfo;
import com.log.blog_backend.service.UserInfoService;
import com.log.blog_backend.utils.TokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author blog
 * @since 2023-01-01
 */
@RestController
@RequestMapping("/userInfo")
@Slf4j
@CrossOrigin
public class UserInfoController {

    @Autowired
    UserInfoService userInfoService;

    @GetMapping("/getUserInfo")
    public Result getUserInfo(HttpServletRequest httpServletRequest){

       return  userInfoService.getUserInfo(httpServletRequest);

    }

    @PostMapping("/updateUserInfo")
    public Result updateUserInfo(@RequestBody UserInfo userInfo){
        boolean save = userInfoService.update(userInfo,null);
      if(save){
          return Result.ok();
      }else {
          return Result.fail("保存失败",6000);
      }
    }

}

